package cn.edu.scau.cmi.linhongxin.client;

import cn.edu.scau.cmi.linhongxin.interProgramming.GraduateStudent;
import cn.edu.scau.cmi.linhongxin.interProgramming.Student;
import cn.edu.scau.cmi.linhongxin.interProgramming.UndergraduateStudent;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;


public class InterProgrammingClient extends Application {

/*	public static void main(String[] args) {
//		Student undergraduateStudent = new UndergraduateStudent();
//		Student graduateStudent = new GraduateStudent();
//			graduateStudent.learning();
//			undergraduateStudent.learning();
		
//		String name  = "Lhx";
//		SingletonClient charmaster = SingletonClient.getInstance(name);
//		System.out.println(charmaster.getName()+charmaster);
//		String newname = "wyb";
//		SingletonClient master = SingletonClient.getInstance(newname);
//		System.out.println(master.getName()+master);
		
	
	}*/
	@FXML
	private AnchorPane AnchorPane;
	@FXML
	private Button button;
	@FXML 
	private TextArea createOutput;
	public void listenButton() {
		button.setOnMouseClicked(new EventHandler<MouseEvent>() {	
			
			@Override
			public void handle(MouseEvent arg) {
				Student undergraduateStudent = new UndergraduateStudent();
				Student graduateStudent = new GraduateStudent();	
			//	createoutput.clear();
				createOutput.appendText(undergraduateStudent.learning()+graduateStudent.learning());				
			}
		});
	}
	@FXML
	public void initialize() {	
		listenButton();
	}
	private Stage PrimaryStage;
	private AnchorPane rootLayout;
	@Override
	public void start(Stage primaryStage) {
		try {
			this.PrimaryStage = primaryStage;
			this.PrimaryStage.setTitle("接口编程");			
			initRootLayout();	
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	public void initRootLayout() {
		try {
			FXMLLoader loader = new FXMLLoader();
			loader.setLocation(InterProgrammingClient.class.getResource("/cn/edu/scau/cmi/linhongxin/interProgramming/InterProgrammingStage.fxml"));
			rootLayout = (AnchorPane) loader.load();			
			Scene scene = new Scene(rootLayout,544,377);
			PrimaryStage.setScene(scene);
			PrimaryStage.show();
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		launch(args);
	}
	
	

}
